/*
 * Copyright (c) 2015 Uwantsoft Ltd.
 * www.uwantsoft.com
 * All rights reserved.
 * This software is the confidential and proprietary information of
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with Uwantsoft.
 */

package com.uwantsoft.business.service;

import com.uwantsoft.business.facade.dto.parking.CityOverviewQueryCondition;
import com.uwantsoft.business.service.domain.city.City;
import com.uwantsoft.business.service.infrastructure.CityRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Leipeichen.
 */
@Service(value = "cityService")
public class CityServiceImpl {

    @Resource(name = "hibernateCityRepository")
    private CityRepository cityRepository;

    public List<City> findCities() {
        return cityRepository.findCities();
    }

    public City findCity(String cityGuid) {
        return cityRepository.findByGuid(cityGuid,City.class);
    }

    public List<City> findCities(CityOverviewQueryCondition condition) {
       return cityRepository.findCities(condition);
    }

    public int findCityTotalNumber(CityOverviewQueryCondition condition) {
        return cityRepository.findCityTotalAmount(condition);
    }

    public void add(City city) {
        cityRepository.save(city);
    }
}
